package servlets;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import tablero.Posicionable;
import tablero.Tablero;

public class CreacionTableroServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
			IOException {
		
		String coordX = request.getParameter("coordX");
		String coordY = request.getParameter("coordY");
		
		
		Tablero tablero = new Tablero(Integer.parseInt(coordX), Integer.parseInt(coordY));
		
		ArrayList<ArrayList<Posicionable>> celdas = tablero.getCeldas();
		
		request.getSession().setAttribute("tablero", tablero);
		
		request.getSession().setAttribute("celdas", celdas);
	

		request.getRequestDispatcher("index.jsp").forward(request, response);
	}
}
